//
//  SelectOvertimePersonViewController.m
//  MobileOffice
//
//  Created by jjkj on 16/11/10.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "SelectOvertimePersonViewController.h"
#import "MarriageTableViewCell.h"
#import "DepartPersonListModel.h"


@interface SelectOvertimePersonViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *tableView;

@end

@implementation SelectOvertimePersonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationTitle:@"人员选择"];
    [self setLeftBackNavigation];
    [self setRightNavigation:@"确认"];
    [self creatView];
    // Do any additional setup after loading the view.
}
#pragma mark -确定按钮
- (void)rightItemClick:(UIBarButtonItem *)item{
    if (_myBlock) {
        _myBlock();
    }
    [self backClick];
}

- (void)creatView{
    //创建列表
    _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT-64) style:UITableViewStylePlain];
    //_myTableView.backgroundColor=[UIColor redColor];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.tag=110;
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _tableView.showsVerticalScrollIndicator=NO;
    _tableView.showsHorizontalScrollIndicator=NO;
    _tableView.bounces=NO;
    //[self addTableViewUpdateRefresh:_tableView BindingIdentity:@""];
    //    [self addTableViewLoadMoreData:_tableView BindingIdentity:@""];
    [self.view addSubview:_tableView];
}

#pragma mark -选择加班人数
- (void)selectButtonClick:(NSIndexPath *)indexPath{
    DepartPersonListModel *model=self.personListModel.dataArr[indexPath.row];
    model.isSelect=!model.isSelect;
    [_tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}


#pragma mark - TableViewDelagate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return _personListModel.dataArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellID=@"MarriageTableViewCell";
    MarriageTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell=[[MarriageTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    DepartPersonListModel *model=self.personListModel.dataArr[indexPath.row];
    //model默认为选中  所以这里要取非
    cell.signButton.selected=model.isSelect;
    cell.myTitleLabel.text=model.empName;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self selectButtonClick:indexPath];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
